wayland: Improve checks when flushing scroll events
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 18 Apr 2016 13:10:49 +0000 (14:10 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 18 Apr 2016 13:14:33 +0000 (14:14 +0100)
If we get gdk_wayland_seat_flush_frame_event() with no previous event to be
flushed, we fallback into the scroll event checks. However, there's no check
performed there as to whether it really scrolled, so it'd always send a smooth
scroll event with 0/0 deltas in this case.

This should be mostly harmless, but still, we should only end up emitting scroll
events if those really happened.

gdk/wayland/gdkdevice-wayland.c

index 4dc498a5c7db23c43b33e9d780734dbfbca5ea31..96e5fb6bea0577bd3b2a2be962b15209bdf2c9c0 100644 (file)
@@ -1142,26 +1142,31 @@ flush_scroll_event (GdkWaylandSeat             *seat,
         direction = GDK_SCROLL_DOWN;
 
       flush_discrete_scroll_event (seat, direction);
+      pointer_frame->discrete_x = 0;
+      pointer_frame->discrete_y = 0;
     }
 
-  /* Axes can stop independently, if we stop on one axis but have a
-   * delta on the other, we don't count it as a stop event.
-   */
-  if (pointer_frame->is_scroll_stop &&
-      pointer_frame->delta_x == 0 &&
-      pointer_frame->delta_y == 0)
-    is_stop = TRUE;
-
-  flush_smooth_scroll_event (seat,
-                             pointer_frame->delta_x,
-                             pointer_frame->delta_y,
-                             is_stop);
-
-  pointer_frame->delta_x = 0;
-  pointer_frame->delta_y = 0;
-  pointer_frame->discrete_x = 0;
-  pointer_frame->discrete_y = 0;
-  pointer_frame->is_scroll_stop = FALSE;
+  if (pointer_frame->is_scroll_stop ||
+      pointer_frame->delta_x != 0 ||
+      pointer_frame->delta_y != 0)
+    {
+      /* Axes can stop independently, if we stop on one axis but have a
+       * delta on the other, we don't count it as a stop event.
+       */
+      if (pointer_frame->is_scroll_stop &&
+          pointer_frame->delta_x == 0 &&
+          pointer_frame->delta_y == 0)
+        is_stop = TRUE;
+
+      flush_smooth_scroll_event (seat,
+                                 pointer_frame->delta_x,
+                                 pointer_frame->delta_y,
+                                 is_stop);
+
+      pointer_frame->delta_x = 0;
+      pointer_frame->delta_y = 0;
+      pointer_frame->is_scroll_stop = FALSE;
+    }
 }
 
 static void